<template>
	<view>
		<uni-nav-bar :border="false" status-bar fixed title="个人中心"></uni-nav-bar>
		<!-- head部分 -->
		<view class="p-3 flex align-center" hover-class="bg-light" hover-stay-time="130" @tap="openLogin">
			<image src="/static/icon/default-head.png" style="height: 130rpx; width: 130rpx;" class="rounded-circle"
			></image>
			<view class="ml-2 flex justify-between flex-1 align-center">
				<view class="flex flex-column" v-if="user.isLogin">
					<text class="font-weight-bold text-dark font-lg">{{ user.nickName }}</text>
					<text class="font text-muted font-md">{{ user.phone }}</text>
				</view>
				<view v-else class="font-lg">
					点击登录
				</view>
				<image src="/static/icon/setup.png" style="width: 70rpx; height: 70rpx;"></image>
			</view>
		</view>
		<view class="flex justify-between px-3 pb-3" v-if="user.isLogin">
			<view class="flex flex-column align-center flex-1 border-right">
				<text class="text-secondary font">用户类型</text>
				<view class="flex align-center mt-1">
					<image src="/static/icon/crown.png" style="width: 35rpx; height: 35rpx;"></image>
					<text class="font-md ml-1">普通用户</text>
				</view>
			</view>
			<view class="flex flex-column align-center flex-1">
				<text class="text-secondary font">注册时间</text>
				<view class="flex align-center mt-1">
					<image src="/static/icon/stopwatch.png" style="width: 35rpx; height: 35rpx;"></image>
					<text class="font-md ml-1">2020-11-10</text>
				</view>
			</view>
		</view>
		<divider></divider>
		
		<!-- 我的审核 -->
		<view v-if="isadmin">
			<view class="flex px-3 pt-3 pb-2 border-bottom">
				<image src="/static/icon/examine.png" style="width: 60rpx; height: 60rpx;"></image>
				<text class="font-lg ml-2">我的审核</text>
			</view>
			<view class="flex flex-wrap">
				<view class="flex flex-column align-center justify-center p-2" @tap="openExamine(1)">
					<image src="/static/icon/old-age-allowance.png" style="width: 70px; height: 70px;"></image>
					<text class="font-md mt-1">高龄津贴</text>
				</view>
				<view class="flex flex-column align-center justify-center p-2" @tap="openExamine(2)">
					<image src="/static/icon/move-out.png" style="width: 70px; height: 70px;"></image>
					<text class="font-md mt-1">迁出</text>
				</view>
			</view>
		</view>
		<view v-else>
			<view class="flex flex-wrap">
				<view class="flex flex-column align-center justify-center p-2" @tap="openProcess">
					<image src="/static/icon/progress.png" style="width: 70px; height: 70px;"></image>
					<text class="font-md mt-1">申请进度</text>
				</view>
				<view class="flex flex-column align-center justify-center p-2" @tap="handleMove">
					<image src="/static/icon/move-out.png" style="width: 70px; height: 70px;"></image>
					<text class="font-md mt-1">我要迁出</text>
				</view>
			</view>
		</view>
		
		<divider></divider>
		<view class="flex px-3 pt-3 pb-2 border-bottom">
			<image src="/static/icon/business-management.png" style="width: 60rpx; height: 60rpx;"></image>
			<text class="font-lg ml-2">任务进度</text>
		</view>
		<view class="flex flex-wrap">
			<view class="flex flex-column align-center justify-center p-2" @tap="openTask(0)">
				<image src="/static/icon/unsettled-business.png" style="width: 70px; height: 70px;"></image>
				<text class="font-md mt-1">待办任务</text>
			</view>
			<view class="flex flex-column align-center justify-center p-2" @tap="openTask(1)">
				<image src="/static/icon/business-done.png" style="width: 70px; height: 70px;"></image>
				<text class="font-md mt-1">已办任务</text>
			</view>
		</view>
		
		<divider></divider>
		<!-- 底部 -->
		<view class="flex align-center px-3 pt-3 pb-2" @tap="openApplicationRecord">
			<image src="/static/icon/browsing-history.png" style="width: 50rpx; height: 50rpx;"></image>
			<view class="flex-1 flex justify-between ml-2">
				<text class="font-md">申请记录</text>
				<image src="/static/icon/next.png" style="width: 40rpx; height: 40rpx;"></image>
			</view>
		</view>
		<view class="flex align-center px-3 py-2" @tap="openAboutUs">
			<image src="/static/icon/about-us.png" style="width: 52rpx; height: 52rpx;"></image>
			<view class="flex-1 flex justify-between ml-2">
				<text class="font-md">关于我们</text>
				<image src="/static/icon/next.png" style="width: 40rpx; height: 40rpx;"></image>
			</view>
		</view>
		<view class="flex align-center px-3 py-2" @tap="openFeedback">
			<image src="/static/icon/feedback.png" style="width: 47rpx; height: 47rpx;"></image>
			<view class="flex-1 flex justify-between ml-2">
				<text class="font-md">意见反馈</text>
				<image src="/static/icon/next.png" style="width: 40rpx; height: 40rpx;"></image>
			</view>
		</view>
		<view style="height: 50rpx;"></view>
	</view>
</template>

<script>
	import uniNavBar from '@/components/uni/uni-nav-bar/uni-nav-bar.vue';
	import divider from '@/components/common/divider.vue';
	
	export default {
		components: {
			uniNavBar,
			divider
		},
		data() {
			return {
				isadmin: false,
				user: {
					nickName: '',
					phone: '',
					isLogin: false
				}
			}
		},
		onLoad() {
			try {
			    this.user.nickName = uni.getStorageSync('nickName');
				this.user.phone = uni.getStorageSync('phone');
				if (this.user.nickName !== '') {
					this.user.isLogin = true
				}
			} catch (e) {
			}
		},
		methods: {
			openLogin () {
				if (!this.user.isLogin) {
					uni.navigateTo({
						url: '../login/login'
					});
				} else {
					// uni.showModal({
					//     title: '提示',
					//     content: '注销登录吗？',
					//     success: (res) => {
					//         if (res.confirm) {
					            
					// 			uni.request({
					// 				url:'http://192.168.78.107:8079/api/app/logout',
					// 				method:'POST',
					// 				success(res) {
					// 					uni.removeStorageSync('nickName');
					// 					uni.removeStorageSync('token');
					// 					uni.removeStorageSync('phone');
					// 					this.user.isLogin = false
					// 				}
					// 			})
					//         } else if (res.cancel) {
					//             console.log('用户点击取消');
					//         }
					//     }
					// });
					uni.navigateTo({
						url: './set/set'
					});
				}
			},
			openTask (e) {
				uni.navigateTo({
					url: `./admin/task?id=${e}`
				})
			},
			openProcess () {
				uni.navigateTo({
					url: './user/application-progress-detail'
				});
			},
			openApplicationRecord () {
				uni.navigateTo({
					url: './user/application-record'
				});
			},
			openAboutUs () {
				uni.navigateTo({
					url: './about-us'
				});
			},
			openFeedback () {
				
				uni.navigateTo({
					url: './feedback'
				});
			},
			handleMove () {
				uni.showModal({
				    title: '您确定要迁出',
				    success: function (res) {
				        if (res.confirm) {
				            // 发出请求处理迁出生请
							uni.showToast({
							    title: '迁出申请已发起,请等待管理员审核',
							    icon: "none"
							});
				        }
				    }
				});
			}
		}
	}
</script>

<style>

</style>
